<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    request.setAttribute("basePath",basePath);
%>
<!DOCTYPE>
<html>
<head>
    <title>设备命令编码</title>
    <%@ include file="/resources/js/easyui/taglibs.jsp"%>
    <%@ include file="/resources/js/easyui/_easyui.jsp"%>
    <%@ include file="/resources/js/easyui/_message.jsp"%>
    <%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body>

<table id="dg"
       title="设备命令编码"
       fitColumns="true"
       singleSelect="true"
       data-options="
       pageSize:10,
       toolbar:'#tb',
       pagination:true,
       collapsible:true,
       url:'${basePath}web/deviceCommand/list.json',
       method:'GET'">
    <thead>

    <tr>
        <th data-options="field:'commandid',checkbox:true,width:10" ></th>
        <th data-options="field:'ntype' ,width:50" align="center">命令类型</th>
        <th data-options="field:'ismo' ,width:60" align="center" formatter="formatterIsmo" >上行下行</th>
        <th data-options="field:'commandcontent' ,width:200" align="center" >命令内容</th>
        <th data-options="field:'errorCode' ,width:60" align="center" formatter="formatterErrorCode" >是否成功</th>
    </tr>

    </thead>
</table>

</body>

<script type="text/javascript">
    function View(){
        var that = this;

        that.events = [
            { sel : '#queryDataBtn', act : 'click', func : 'queryData' }
        ];

        that.$dataGrid = $('#dg');

        that.dataGridOption = {
            queryParams : {
                hardwareName : function(){return $('#hardwareName').val();}
            }
        };

        $.extend(that.dataGridOption, ViewHelper.template.gridOption);

        that.$dataGrid.datagrid(that.dataGridOption);

        that.queryData = function () {
            that.$dataGrid.datagrid(that.dataGridOption);
        };

        EventHandler.call(that, that.events);

        return that;
    }

    var view;

    $(function(){
        inherit(View, EventHandler);
        view = new View();
    });

    function formatterIsmo(value,row,index){
        if(row.ismo==0){
            return "上行";
        }else{
            return "下行";
        }
    }

    function formatterErrorCode(value,row,index){
        if(row.ismo==0){
            return "成功";
        }else{
            return "失败";
        }
    }

</script>

</html>